package com.heatup.apt.management.controller;

import com.alibaba.druid.util.StringUtils;

/**
 * Created by earvin on 2017/8/3.
 */

import com.heatup.apt.management.service.order.*;
import com.heatup.apt.common.util.JsonTools;
import com.heatup.apt.common.util.RequestTools;
import com.heatup.apt.common.util.ResponseTools;
import com.heatup.apt.model.api.ApiResultModel;
import com.heatup.apt.model.order.OrderInFoToTK;
import org.slf4j.*;
import org.springframework.beans.factory.annotation.*;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.*;

import javax.servlet.http.*;
import java.util.*;

/**
 * 订单管理
 */
@Controller
@RequestMapping("system/order")
public class OrderManageController extends BaseController{
    private static final Logger log = LoggerFactory.getLogger(OrderManageController.class);

    @Autowired
    private OrderManageService orderManageService;



    /**
     * 跳转团课列表
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/to_team_order_list")
    public ModelAndView toTeamOrderList(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView model = new ModelAndView();
        model.addObject("userInfo",this.getUserInfo());
        model.setViewName("order/order-list");
        return model;
    }

    /**
     * 获取团课列表
     *
     * @param request
     * @param response
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/getTeamOrderList")
    public String getTeamOrderList(HttpServletRequest request, HttpServletResponse response){
        ApiResultModel<Object> apiResultModel = new ApiResultModel<Object>();
        Map<String, Object> map = new HashMap<String, Object>();
        List<OrderInFoToTK> list = null;
        Map<String, Object> paramMap = new HashMap<String, Object>();
        String callback = RequestTools.RequestString(request, "callback", null);
        String course_stime = RequestTools.RequestString(request, "course_stime", null);
        String course_etime = RequestTools.RequestString(request, "course_etime", null);
        String course_id = RequestTools.RequestString(request, "course_id", null);
        String mobile = RequestTools.RequestString(request, "mobile", null);
        String store_id = RequestTools.RequestString(request, "store_id", "0");
        String type = RequestTools.RequestString(request, "type", null);
        String pageNums = RequestTools.RequestString(request, "pageNum", "1");
        String tradeId =  RequestTools.RequestString(request, "tradeId", null);
        String coachId = RequestTools.RequestString(request, "coach_id","0");
        Integer userId = RequestTools.RequestInt(request, "userId", 0);
        String userName = RequestTools.RequestString(request, "userName", null);
        paramMap.put("course_stime", course_stime);
        paramMap.put("course_etime", course_etime);
        paramMap.put("course_id", course_id);
        paramMap.put("mobile", mobile);
        paramMap.put("store_id", store_id);
        paramMap.put("type", type);
        paramMap.put("tradeId",tradeId);
        paramMap.put("coachId", coachId);
        paramMap.put("userId", userId);
        paramMap.put("userName", userName);
        int pageNum = Integer.valueOf(pageNums);
        int pageIndex =0;
        if (pageNum == 1) {
            pageIndex = 0;
        } else {
            pageIndex = (pageNum - 1) * 20;

        }
        paramMap.put("pageNum", pageIndex);
        paramMap.put("pageCount", 20);
        try {
            Map<String, Object> respMap = orderManageService.getTeamOrderList(paramMap);
            respMap.put("pageNum",pageNum);
            respMap.put("pageIndex",pageIndex);
            apiResultModel.setData(respMap);
            apiResultModel.setRet(ApiResultModel.RET_SUCCESS);
            apiResultModel.setMsg("获取所有团课数据");
        } catch (Exception e) {
            apiResultModel.setData("系统错误");
            apiResultModel.setMsg("获取失败");
            apiResultModel.setRet(ApiResultModel.RET_ERROR);
            e.printStackTrace();
        }
        return ResponseTools.CallBackResultJsonP(JsonTools.jsonSer(apiResultModel), callback);
    }
    
    /**
     * 私教列表界面
     * 私教体验订单列表
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("/to_personal_order_list")
    public ModelAndView toPersonalOrderList(HttpServletRequest request,HttpServletResponse response){
    	ModelAndView modelAndView = new ModelAndView();
    	modelAndView.addObject("userInfo", this.getUserInfo());
    	modelAndView.setViewName("order/order-personal-list");
    	return modelAndView;
    }
    
    /**
     * 获取私教订单列表
     * @return
     */
    @ResponseBody
    @RequestMapping("/get_personal_order_list")
    public String getPersonalOrderList(HttpServletRequest request,HttpServletResponse response){
    	List<OrderInFoToTK> listData = new ArrayList<OrderInFoToTK>();
		String callback = RequestTools.RequestString(request, "callback", "");
		ApiResultModel<Object> apiResultModel = new ApiResultModel<Object>();
		Map<String, Object> mapWhere = new HashMap<String, Object>();
		String type = RequestTools.RequestString(request, "type", "");
		String course_stime = RequestTools.RequestString(request, "course_stime", null);
		String course_etime = RequestTools.RequestString(request, "course_etime", null);
		String course_id = RequestTools.RequestString(request, "course_id", null);
		String mobile = RequestTools.RequestString(request, "mobile", null);
		String store_id = RequestTools.RequestString(request, "store_id", "0");
		String pageNums = RequestTools.RequestString(request, "pageNum", "1");
		String tradeId =  RequestTools.RequestString(request, "tradeId", null);
		String coachId = RequestTools.RequestString(request, "coach_id", "0");
		Integer userId = RequestTools.RequestInt(request, "userId", 0);
		String userName = RequestTools.RequestString(request, "userName", null);
		mapWhere.put("course_stime", course_stime);
		mapWhere.put("course_etime", course_etime);
		mapWhere.put("course_id", course_id);
		mapWhere.put("mobile", mobile);
		mapWhere.put("store_id", store_id);
		mapWhere.put("type", type);
		mapWhere.put("tradeId", tradeId);
		mapWhere.put("coachId",coachId);
		mapWhere.put("userId", userId);
		mapWhere.put("userName", userName);
		try {
			int pageNum = Integer.valueOf(pageNums);
	        int pageIndex =0;
	        if (pageNum == 1) {
	            pageIndex = 0;
	        } else {
	            pageIndex = (pageNum - 1) * 20;

	        }
			mapWhere.put("pageNum", pageIndex);
			mapWhere.put("pageCount", 20);
			Map<String, Object> mapD = new HashMap<String, Object>();
			mapD = orderManageService.getPersonalOrderList(mapWhere);
			mapWhere.put("pageNum", pageNum);
			apiResultModel.setData(mapD);
			apiResultModel.setRet(ApiResultModel.RET_SUCCESS);
			apiResultModel.setLogined(true);
		} catch (Exception e) {
			apiResultModel.setRet(ApiResultModel.RET_ERROR);
			apiResultModel.setLogined(true);
			apiResultModel.setData("获取数据失败");
			e.printStackTrace();
		}
		return ResponseTools.CallBackResultJsonP(JsonTools.jsonSer(apiResultModel), callback);
    }
    
    /**
     * 跳转檬营订单列表
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("/to_fun_camp_order_list")
    public ModelAndView toFunCampOrderList(HttpServletRequest request, HttpServletResponse response){
    	ModelAndView modelAndView = new ModelAndView();
    	modelAndView.addObject("userInfo", this.getUserInfo());
    	modelAndView.setViewName("order/order-camp-list");
    	return modelAndView;
    }
    
    /**
     * 获取檬营订单列表
     * @param request
     * @param response
     * @return
     */
    @ResponseBody
    @RequestMapping("/get_fun_camp_order_list")
    public String getFunCampOrderList(HttpServletRequest request, HttpServletResponse response){
    	List<OrderInFoToTK> listData = new ArrayList<OrderInFoToTK>();
		String callback = RequestTools.RequestString(request, "callback", "");
		ApiResultModel<Object> apiResultModel = new ApiResultModel<Object>();
		Map<String, Object> mapWhere = new HashMap<String, Object>();
		String type = RequestTools.RequestString(request, "type", "");
		String pageNums = RequestTools.RequestString(request, "pageNum", "1");
		String course_stime = RequestTools.RequestString(request, "course_stime", null);
		String course_etime = RequestTools.RequestString(request, "course_etime", null);
		String course_id = RequestTools.RequestString(request, "course_id", null);
		String mobile = RequestTools.RequestString(request, "mobile", null);
		String store_ids = RequestTools.RequestString(request, "store_id", "0");
		String tradeId =  RequestTools.RequestString(request, "tradeId", null);
		Integer userId = RequestTools.RequestInt(request, "userId", 0);
		String userName = RequestTools.RequestString(request, "userName", null);
		try {
			mapWhere.put("type", type);
			mapWhere.put("course_stime", course_stime);
			mapWhere.put("course_etime", course_etime);
			mapWhere.put("course_id", course_id);
			mapWhere.put("mobile", mobile);
			mapWhere.put("store_id", store_ids);
			mapWhere.put("tradeId", tradeId);
			mapWhere.put("userId", userId);
			mapWhere.put("userName", userName);
			int pageNum = Integer.valueOf(pageNums);
	        int pageIndex =0;
	        if (pageNum == 1) {
	            pageIndex = 0;
	        } else {
	            pageIndex = (pageNum - 1) * 20;

	        }
			mapWhere.put("pageNum", pageIndex);
			mapWhere.put("pageCount", 20);
			Map<String, Object> mapD = new HashMap<String, Object>();
			mapD = orderManageService.getFunCampOrderList(mapWhere);
			mapD.put("pageNum", pageNum);
			apiResultModel.setRet(ApiResultModel.RET_SUCCESS);
			apiResultModel.setLogined(true);
			apiResultModel.setData(mapD);
		} catch (Exception e) {
			apiResultModel.setRet(ApiResultModel.RET_ERROR);
			apiResultModel.setLogined(true);
			apiResultModel.setData("获取数据失败");
			e.printStackTrace();

		}
		return ResponseTools.CallBackResultJsonP(JsonTools.jsonSer(apiResultModel), callback);
    }
    
    /**
     * 跳转自助健身订单列表
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("/to_self_order_list")
    public ModelAndView toSelfOrderList(HttpServletRequest request, HttpServletResponse response){
    	ModelAndView modelAndView = new ModelAndView();
    	modelAndView.addObject("userInfo", this.getUserInfo());
    	modelAndView.setViewName("order/order-self-list");
    	return modelAndView;
    }
    
    /**
     * 私教体验订单列表查询
     * @param request
     * @param response
     * @return
     */
    @ResponseBody
    @RequestMapping("/get_self_order_list")
    public String getSelfOrderList(HttpServletRequest request, HttpServletResponse response){
    	List<OrderInFoToTK> listData = new ArrayList<OrderInFoToTK>();
		String callback = RequestTools.RequestString(request, "callback", "");
		ApiResultModel<Object> apiResultModel = new ApiResultModel<Object>();
		Map<String, Object> mapWhere = new HashMap<String, Object>();
		apiResultModel.setMsg("获取数据失败！");
		apiResultModel.setData("获取数据失败！");
		apiResultModel.setRet(ApiResultModel.RET_ERROR);
		String type = RequestTools.RequestString(request, "type", "");
		String pageNums = RequestTools.RequestString(request, "pageNum", "1");
		String course_stime = RequestTools.RequestString(request, "course_stime", null);
		String course_etime = RequestTools.RequestString(request, "course_etime", null);
		String title = RequestTools.RequestString(request, "title", null);
		String mobile = RequestTools.RequestString(request, "mobile", null);
		String store_id = RequestTools.RequestString(request, "store_id", "0");
		String tradeId =  RequestTools.RequestString(request, "tradeId", null);
		Integer userId = RequestTools.RequestInt(request, "userId", 0);
		String userName = RequestTools.RequestString(request, "userName", null);
		mapWhere.put("course_stime", course_stime);
		mapWhere.put("course_etime", course_etime);
		mapWhere.put("title", title);
		mapWhere.put("mobile", mobile);
		mapWhere.put("store_id", store_id);
		mapWhere.put("type", type);
		mapWhere.put("tradeId", tradeId);
		mapWhere.put("userId", userId);
		mapWhere.put("userName", userName);
		try {
			int pageNum = Integer.valueOf(pageNums);
	        int pageIndex =0;
	        if (pageNum == 1) {
	            pageIndex = 0;
	        } else {
	            pageIndex = (pageNum - 1) * 20;
	        }
	        
			mapWhere.put("pageNum", pageIndex);
			mapWhere.put("pageCount", 20);
			Map<String, Object> mapD = new HashMap<String, Object>();
			mapD = orderManageService.getSelfOrderList(mapWhere);
			mapD.put("pageNum", pageNum);
			apiResultModel.setMsg("获取自助健身订单数据");
			apiResultModel.setData(mapD);
			apiResultModel.setRet(ApiResultModel.RET_SUCCESS);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return ResponseTools.CallBackResultJsonP(JsonTools.jsonSer(apiResultModel), callback);
    }
    
    /**
     * 跳转体测券订单列表
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/to_se_order_list")
    public ModelAndView toSeOrderList(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView model = new ModelAndView();
        model.addObject("userInfo",this.getUserInfo());
        model.setViewName("order/order-se-list");
        return model;
    }
    
    /**
     * 获取体测订单列表
     * @param request
     * @param response
     * @return
     */
    @ResponseBody
    @RequestMapping(value="/get_se_order_list")
    public String getSecretExperienceOrderList(HttpServletRequest request, HttpServletResponse response){
        ApiResultModel<Object> model = new ApiResultModel<Object>();
        String callback = RequestTools.RequestString(request, "callback", null);
        String mobile = RequestTools.RequestString(request, "mobile", null);
        String storeId = RequestTools.RequestString(request, "storeId", "0");
        String type = RequestTools.RequestString(request, "type", null);
        int pageNum = RequestTools.RequestInt(request, "pageNum", 1);
        String orderNumber =  RequestTools.RequestString(request, "orderNumber", null);
        String coachId = RequestTools.RequestString(request, "coachId","0");
        Integer userId = RequestTools.RequestInt(request, "userId", 0);
        String nickName = RequestTools.RequestString(request, "nickName", null);
        Integer orderType = RequestTools.RequestInt(request, "orderType", 9);
//        Integer orderStatus = RequestTools.RequestInt(request, "orderStatus", 1);
        
        Map<String,Object> param = new HashMap<>();
        param.put("mobile",mobile);
        param.put("storeId",storeId);
        param.put("type",type);
        param.put("pageNum",pageNum);
        param.put("orderNumber",orderNumber);
        param.put("coachId",coachId);
        param.put("userId",userId);
        param.put("nickName",nickName);
        param.put("orderType", orderType);
//        param.put("orderStatus", orderStatus);
        
        Integer pageIndex = pageNum;
        Integer pageSize = Integer.valueOf(20);
        if (pageNum == 1) {
            pageIndex = 0;
        } else {
            pageIndex = (pageNum - 1) * pageSize;

        }
        param.put("pageIndex", pageIndex);
        param.put("pageSize", 20);

        try{
            Map<String,Object> respMap = orderManageService.getSeOrderList(param);
            respMap.put("pageNum",pageNum);
            model.setData(respMap);
            model.setRet(ApiResultModel.RET_SUCCESS);
        }catch (Exception e){
            e.printStackTrace();
            log.error("查询私教体侧订单失败",e);
            model.setRet(ApiResultModel.RET_ERROR);
            model.setMsg("查询私体侧订单失败");
        }

        return ResponseTools.CallBackResultJsonP(JsonTools.jsonSer(model), callback);
    }
    
    /**
     * 跳转私教体验订单列表
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("/to_personal_experience_order_list")
    public ModelAndView toPersonalExperienceOrderList(HttpServletRequest request, HttpServletResponse response) {
    	ModelAndView modelAndView = new ModelAndView();
    	modelAndView.addObject("userInfo", this.getUserInfo());
    	modelAndView.setViewName("order/order-private-experience-list");
    	return modelAndView;
    }
    
    /**
     * 获取私教订单列表
     * @param request
     * @param response
     * @return
     */
    @ResponseBody
    @RequestMapping("/get_personal_experience_order_list")
    public String getPersonalExperienceOrderList(HttpServletRequest request, HttpServletResponse response) {
    	ApiResultModel<Object> model = new ApiResultModel<Object>();
        String callback = RequestTools.RequestString(request, "callback", null);
        String mobile = RequestTools.RequestString(request, "mobile", null);
        String storeId = RequestTools.RequestString(request, "storeId", "0");
        String type = RequestTools.RequestString(request, "type", null);
        int pageNum = RequestTools.RequestInt(request, "pageNum", 1);
        String orderNumber =  RequestTools.RequestString(request, "orderNumber", null);
        String coachId = RequestTools.RequestString(request, "coachId","0");
        Integer userId = RequestTools.RequestInt(request, "userId", 0);
        String nickName = RequestTools.RequestString(request, "nickName", null);
        Integer orderType = RequestTools.RequestInt(request, "orderType", 9);
        
        Map<String,Object> param = new HashMap<>();
        param.put("mobile",mobile);
        param.put("storeId",storeId);
        param.put("type",type);
        param.put("pageNum",pageNum);
        param.put("orderNumber",orderNumber);
        param.put("coachId",coachId);
        param.put("userId",userId);
        param.put("nickName",nickName);
        param.put("orderType", orderType);
        
        Integer pageIndex = pageNum;
        Integer pageSize = Integer.valueOf(20);
        if (pageNum == 1) {
            pageIndex = 0;
        } else {
            pageIndex = (pageNum - 1) * pageSize;

        }
        param.put("pageIndex", pageIndex);
        param.put("pageSize", 20);

        try{
            Map<String,Object> respMap = orderManageService.getSeOrderList(param);
            respMap.put("pageNum",pageNum);
            model.setData(respMap);
            model.setRet(ApiResultModel.RET_SUCCESS);
        }catch (Exception e){
            e.printStackTrace();
            log.error("查询私教体验课订单失败",e);
            model.setRet(ApiResultModel.RET_ERROR);
            model.setMsg("查询私教体验课订单失败");
        }

        return ResponseTools.CallBackResultJsonP(JsonTools.jsonSer(model), callback);
    }
    
    /**
     * 跳转私教预约订单列表
     * 私教咨询
     * @return
     */
    @RequestMapping("/to_private_bespeak_order_list")
    public ModelAndView toPrivateBespeakOrderList(){
    	ModelAndView modelAndView = new ModelAndView();
    	modelAndView.addObject("userInfo", this.getUserInfo());
    	modelAndView.setViewName("order/order-private-bespeak-order-list");
    	return modelAndView;
    }
    
    /**
     * 获取私教预约订单列表
     * 私教咨询
     * @param request
     * @param response
     * @return
     */
    @ResponseBody
    @RequestMapping("/get_private_bespeak_order_list")
    public String getPrivateBespeakOrderList(HttpServletRequest request, HttpServletResponse response){
    	ApiResultModel<Object> model = new ApiResultModel<Object>();
        String callback = RequestTools.RequestString(request, "callback", null);
        String mobile = RequestTools.RequestString(request, "mobile", null);
        String storeId = RequestTools.RequestString(request, "storeId", "0");
        String type = RequestTools.RequestString(request, "type", null);
        int pageNum = RequestTools.RequestInt(request, "pageNum", 1);
        String orderNumber =  RequestTools.RequestString(request, "orderNumber", null);
        String coachId = RequestTools.RequestString(request, "coachId","0");
        Integer userId = RequestTools.RequestInt(request, "userId", 0);
        String nickName = RequestTools.RequestString(request, "nickName", null);
        Integer orderType = RequestTools.RequestInt(request, "orderType", 9);
        
        Map<String,Object> param = new HashMap<>();
        param.put("mobile",mobile);
        param.put("storeId",storeId);
        param.put("type",type);
        param.put("pageNum",pageNum);
        param.put("orderNumber",orderNumber);
        param.put("coachId",coachId);
        param.put("userId",userId);
        param.put("nickName",nickName);
        param.put("orderType", orderType);
        
        Integer pageIndex = pageNum;
        Integer pageSize = Integer.valueOf(20);
        if (pageNum == 1) {
            pageIndex = 0;
        } else {
            pageIndex = (pageNum - 1) * pageSize;

        }
        param.put("pageIndex", pageIndex);
        param.put("pageSize", 20);

        try{
            Map<String,Object> respMap = orderManageService.getPrivateBespeakOrderList(param);
            respMap.put("pageNum",pageNum);
            model.setData(respMap);
            model.setRet(ApiResultModel.RET_SUCCESS);
        }catch (Exception e){
            e.printStackTrace();
            log.error("查询私教体预约订单失败",e);
            model.setRet(ApiResultModel.RET_ERROR);
            model.setMsg("查询私教体预约订单失败");
        }

        return ResponseTools.CallBackResultJsonP(JsonTools.jsonSer(model), callback);
    	
    }
    
    @ResponseBody
    @RequestMapping("/transference_order")
    public String transferenceOrder(HttpServletRequest request, HttpServletResponse response){
    	ApiResultModel<Object> apiResultModel = new ApiResultModel<>();
    	String callback = RequestTools.RequestString(request, "callback", null);
    	Integer orderId = RequestTools.RequestInt(request, "orderId", 0);
    	Integer coachId = RequestTools.RequestInt(request, "coachId", 0);
    	Integer type 	= RequestTools.RequestInt(request, "type", 0);
		String student	= RequestTools.RequestString(request, "student", "");
    	Map<String,Object> parmMap = new HashMap<>();
    	try {
    		parmMap.put("orderId", orderId);
    		parmMap.put("coachId", coachId);
    		parmMap.put("type", type);
    		parmMap.put("student", student);
    		if(orderManageService.transferenceOrder(parmMap) > 0){
    			apiResultModel.setRet(ApiResultModel.RET_SUCCESS);
    			apiResultModel.setMsg("转单成功！");
    			apiResultModel.setData("转单成功！");
    		}else{
    			apiResultModel.setRet(ApiResultModel.RET_ERROR);
    			apiResultModel.setMsg("转单失败！");
    			apiResultModel.setData("转单失败！");
    		}
		} catch (Exception e) {
			apiResultModel.setRet(ApiResultModel.RET_ERROR);
			apiResultModel.setMsg("转单失败！");
			apiResultModel.setData("转单失败！");
			log.error("================== transferenceOrder error :"+e.toString()+e.getCause()+e);
		}
    	return ResponseTools.CallBackResultJsonP(JsonTools.jsonSer(apiResultModel), callback);
    }
    
    @RequestMapping("/to_refund_order")
    public ModelAndView toRefundOrderList(HttpServletRequest request,HttpServletResponse response){
    	ModelAndView modelAndView = new ModelAndView();
    	modelAndView.setViewName("order/order-refund");
    	modelAndView.addObject("userInfo", this.getUserInfo());
    	return modelAndView;
    }
    
    /**
     * 根据订单号查询订单
     * @param request
     * @param response
     * @return
     */
    @ResponseBody
    @RequestMapping("get_refund_order_list")
    public String getRefundOrderList(HttpServletRequest request,HttpServletResponse response){
    	ApiResultModel<Object> apiResultModel = new ApiResultModel<>();
    	String orderNumber = RequestTools.RequestString(request, "orderNumber", null);
    	String callback    = RequestTools.RequestString(request, "callback", "");
    	Map<String,Object> parmaMap = new HashMap<>();
    	if(StringUtils.isEmpty(orderNumber.trim())){
    		apiResultModel.setMsg("订单号不正确！");
    		apiResultModel.setRet(apiResultModel.RET_ERROR);
    		apiResultModel.setData("订单号不正确！");
    		return ResponseTools.CallBackResultJsonP(JsonTools.jsonSer(apiResultModel), callback);
    	}
    	try {
    		parmaMap.put("orderNumber", orderNumber.trim());
    		parmaMap = orderManageService.getOrderListByOrderNumber(parmaMap);
    		apiResultModel.setData(parmaMap);
    		apiResultModel.setRet(apiResultModel.RET_SUCCESS);
    		
		} catch (Exception e) {
			apiResultModel.setMsg("系统运行异常！");
    		apiResultModel.setRet(apiResultModel.RET_ERROR);
    		apiResultModel.setData("系统运行异常！");
    		log.error("============== getRefundOrderList error :"+e.toString()+e.getCause(),e);
		}
    	return ResponseTools.CallBackResultJsonP(JsonTools.jsonSer(apiResultModel), callback);
    }
    
    
    @RequestMapping("/to_order_bill_detail")
    public ModelAndView toOrderBillDetail(HttpServletRequest request, HttpServletResponse response) {
    	ModelAndView modelAndView = new ModelAndView();
    	modelAndView.setViewName("/order/open_bill_details");
    	Integer orderId = RequestTools.RequestInt(request, "orderId", 0);
    	Map<String,Object> resultMap = new HashMap<>();
    	try {
			
    		resultMap = orderManageService.getOpenYearCardOrderDetail(orderId);
    		modelAndView.addAllObjects(resultMap);
		} catch (Exception e) {
			// TODO: handle exception
			modelAndView.addObject("resul_code", "error");
			log.info(" toOrderBillDetail | error:"+e.toString()+e.getCause(),e);
		}
    	return modelAndView;
    }
    

}
